package SimpleLogger;
use strict;
use warnings;
use Exporter 'import';

our @EXPORT  =  qw($DEBUG $INFO $WARN $ERROR $FATAL);

our $DEBUG = 0;
our $INFO  = 1;
our $WARN  = 2;
our $ERROR = 3;
our $FATAL = 4;

our $loglevel  =  0;

sub new {
    my $class = shift;
	$loglevel = shift;

	my $self = {}; 
	bless ($self, $class);
	return $self;
}

sub log {
    my ($self, $message, $level) = @_;
	if ($level >= $loglevel) {
		my $datetime = localtime();
		printf ("%-26s%-55.55s(%s)\n", $datetime, $message, $level);
	}
}

sub debug {
    my ($self, $message) = @_;
	$self->log($message, $DEBUG);
}

sub info {
    my ($self, $message) = @_;
	$self->log($message, $INFO);
}

sub warn {
    my ($self, $message) = @_;
	$self->log($message, $WARN);
}

sub error {
    my ($self, $message) = @_;
	$self->log($message, $ERROR);
}

sub fatal {
    my ($self, $message) = @_;
	$self->log($message, $FATAL);
}

1;